-- 关闭公告
local function guanbigonggao()
  local b
  local args = {"653|299|4BE3FE,637|295|020418,32|295|069EE7,338|255|8DFEFE,47|385|CEE3F0,673|989|0CD7FD", 0.9}
  local x, y = 657, 293
  local ret = LuaAuxLib.CmpColorEx(args[1], args[2])
  b = ret == 1
  if b then
    LuaAuxLib.TracePrint("游戏公告界面，点击关闭")
    LuaAuxLib.Tap(x, y)
  end
  return b
end

-- 跳过剧情
local function tiaoguojuqing()
  local args = {521, 20, 719, 95, "E7FAFE", "38|-12|101351,57|-1|E7FAFE,14|6|2B2CBD,-67|-8|060638", 0, 0.9}
  local offsetX, offsetY = 0, 0
  local x, y = LuaAuxLib.FindMultiColor(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8])
  local b = false
  if x >= 0 and y >= 0 then
    LuaAuxLib.TracePrint("发现跳过剧情按钮，点击")
    LuaAuxLib.Tap(x + offsetX, y + offsetY)
    b = true
  end
  return b
end

-- 指引手
local function zhiyinshou()
<<<<<<< HEAD
  local args = {0, 0, 0, 0, "755892", "13|-11|6FBCCB,19|-18|F8C83F,11|-2|D7E387,0|14|373035,35|3|8C769D,27|13|65C7D9", 0, 0.9}
=======
  local args = {
    0,
    0,
    0,
    0,
    "755892",
    "13|-11|6FBCCB,19|-18|F8C83F,11|-2|D7E387,0|14|373035,35|3|8C769D,27|13|65C7D9",
    0,
    0.9
  }
>>>>>>> f277baccc0fbff749e4ef4260c26baf2fd46764d
  local offsetX, offsetY = -57, -83
  local x, y = LuaAuxLib.FindMultiColor(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8])
  local b = false
  if x >= 0 and y >= 0 then
    LuaAuxLib.TracePrint("发现指引手图标，点击")
    LuaAuxLib.Tap(x + offsetX, y + offsetY)
    b = true
  end
  return b
end

-- 连接失败弹窗
local function liejieshibai()
  local args = {
    252,
    566,
    468,
    721,
    "D3F5FC",
    "42|-11|D7F9FF,-16|10|182F5B,-63|-91|C8E6F7,1|-96|CEEEFF,104|-97|CEEEFF,107|20|1662AB",
    0,
    0.9
  }
  local offsetX, offsetY = 0, 0
  local x, y = LuaAuxLib.FindMultiColor(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8])
  local b = false
  if x >= 0 and y >= 0 then
    LuaAuxLib.TracePrint("发现连接失败弹窗，点击确定")
    LuaAuxLib.Tap(x + offsetX, y + offsetY)
    b = true
  end
  return b
end

-- 剧情对话
local function juqingduihua()
  local args = {
    5,
    1008,
    711,
    1040,
    "76CEEF",
    "-183|1|5D9DB5,-320|0|76CEEF,204|1|5FA0B8,366|0|76CEEF,386|1|5C9DB5",
    0,
    0.9
  }
  local offsetX, offsetY = 0, -100
  local x, y = LuaAuxLib.FindMultiColor(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8])
  local b = false
  if x >= 0 and y >= 0 then
    LuaAuxLib.TracePrint("发现剧情对话，点击跳过")
    LuaAuxLib.Tap(x + offsetX, y + offsetY)
    b = true
  end
  return b
end

-- 通用处理主函数
local function start()
  local b
  local funcs = {
    tiaoguojuqing,
    guanbigonggao,
    zhiyinshou,
    liejieshibai,
    juqingduihua
  }
  for _, func in ipairs(funcs) do
    b = func()
    if b then
      break
    end
  end
  return b
end

function QMPlugin.RegisterModule()
  LuaAuxLib.TracePrint("注册通用模块")
  LuaAuxLib.Modules = LuaAuxLib.Modules or {}
  LuaAuxLib.Modules.Jp_Tongyong = LuaAuxLib.Modules.Jp_Tongyong or {}
  LuaAuxLib.Modules.Jp_Tongyong.start = start
  LuaAuxLib.Modules.Jp_Tongyong.guanbigonggao = guanbigonggao
  LuaAuxLib.Modules.Jp_Tongyong.tiaoguojuqing = tiaoguojuqing
  LuaAuxLib.Modules.Jp_Tongyong.zhiyinshou = zhiyinshou
  LuaAuxLib.Modules.Jp_Tongyong.liejieshibai = liejieshibai
  LuaAuxLib.Modules.Jp_Tongyong.juqingduihua = juqingduihua
end
